#ifndef		__ENGINE_IOLISTENER_H_INCLUDED__
#define		__ENGINE_IOLISTENER_H_INCLUDED__

#define		IO_NONE			0
#define		IO_READ			1
#define		IO_WRITE		2
#define		IO_READWRITE	3

/** Interface for listen IO event */
struct IOListener {

	/**
	 * Bind listener on given file descriptor(or SOCKET on windows)
	 *
	 * \param fd File descriptor or SOCKET on windows.
	 * \param events Listen events.
	 */
	void BindIO(int fd, int events);

	/**
	 * Wait for given events raised once. 
	 *
	 * \param event Event type waiting raised.
	 */
	void WaitIO(int event);

	/** Unbind listener on attached file descriptor */
	void UnbindIO();

	/** Interface to handle readable event */
	virtual void OnReadable() {};

	/** Interface to handle writable event */
	virtual void OnWritable() {};

private:
	int _binded_io_fd;
};

#endif//!	__ENGINE_IOLISTENER_H_INCLUDED__
